]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
extensionSystem: Fix deferred loading of extensions
authorJasper St. Pierre <jstpierre@mecheye.net>
Tue, 25 Oct 2011 18:38:25 +0000 (14:38 -0400)
committerJasper St. Pierre <jstpierre@mecheye.net>
Thu, 27 Oct 2011 21:21:49 +0000 (17:21 -0400)
We need to show the list of installed extensions on EGO, so we can't defer
loading by not creating the extension meta.

https://bugzilla.gnome.org/show_bug.cgi?id=662704

js/ui/extensionSystem.js
js/ui/lookingGlass.js

index 95c3a29ed7ff967963cb6d37729d2d11edc2b603..66f0904d7737e91c9544c088f6acda3986ca7e9d 100644 (file)
@@ -22,6 +22,7 @@ const ExtensionState = {
     ERROR: 3,
     OUT_OF_DATE: 4,
     DOWNLOADING: 5,
+    INITIALIZED: 6,
 
     // Used as an error state for operations on unknown extensions,
     // should never be in a real extensionMeta object.
@@ -62,8 +63,6 @@ const extensionMeta = {};
 const extensions = {};
 // Maps uuid -> extension state object (returned from init())
 const extensionStateObjs = {};
-// Maps uuid -> [GFile to the extension directory, Extension type]
-const extensionDirs = {};
 // Contains the order that extensions were enabled in.
 const extensionOrder = [];
 
@@ -260,11 +259,11 @@ function disableExtension(uuid) {
 
 function enableExtension(uuid) {
     let meta = extensionMeta[uuid];
-    if (!meta) {
-        if (extensionDirs[uuid]) {
-            let [dir, type] = extensionDirs[uuid];
-            loadExtension(dir, type);
-        }
+    if (!meta)
+        return;
+
+    if (meta.state == ExtensionState.INITIALIZED) {
+        loadExtension(meta.dir, meta.type, true);
         return;
     }
 
@@ -296,7 +295,7 @@ function logExtensionError(uuid, message, state) {
                                                state: state });
 }
 
-function loadExtension(dir, type) {
+function loadExtension(dir, type, enabled) {
     let info;
     let uuid = dir.get_basename();
 
@@ -353,6 +352,7 @@ function loadExtension(dir, type) {
 
     extensionMeta[uuid] = meta;
     meta.type = type;
+    meta.dir = dir;
     meta.path = dir.get_path();
     meta.error = '';
 
@@ -366,6 +366,11 @@ function loadExtension(dir, type) {
         return;
     }
 
+    if (!enabled) {
+        meta.state = ExtensionState.INITIALIZED;
+        return;
+    }
+
     let extensionJs = dir.get_child('extension.js');
     if (!extensionJs.query_exists(null)) {
         logExtensionError(uuid, 'Missing extension.js');
@@ -485,9 +490,7 @@ function _loadExtensionsIn(dir, type) {
         let name = info.get_name();
         let child = dir.get_child(name);
         let enabled = enabledExtensions.indexOf(name) != -1;
-        extensionDirs[name] = [dir, type];
-        if (enabled)
-            loadExtension(child, type);
+        loadExtension(child, type, enabled);
     }
     fileEnum.close(null);
 }
index 0f0dfe901123662e981d8d1896c99a96b9a2b301..4e383b364ac0c0bf419604d25a409f7dc60f8091 100644 (file)
@@ -737,6 +737,7 @@ Extensions.prototype = {
             case ExtensionSystem.ExtensionState.ENABLED:
                 return _("Enabled");
             case ExtensionSystem.ExtensionState.DISABLED:
+            case ExtensionSystem.ExtensionState.INITIALIZED:
                 return _("Disabled");
             case ExtensionSystem.ExtensionState.ERROR:
                 return _("Error");